package com.icbc.dccsh.storm.mongodb.mapper;

import org.bson.Document;

import backtype.storm.tuple.ITuple;

public class SimpleMongoMapper implements MongoMapper {
	private String[] fields;

    @Override
    public Document toDocument(ITuple tuple) {
        Document document = new Document();
        for(String field : fields){
            document.append(field, tuple.getValueByField(field));
        }
        return document;
    }

    public SimpleMongoMapper withFields(String... fields) {
        this.fields = fields;
        return this;
    }
}
